<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#itemList {
    width:95%
}
#itemAction {
padding-left: 1.1em;
word-spacing:normal;
text-align:left;
}
</style>
<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>

<SCRIPT LANGUAGE="JavaScript">
var checkedAll = false;

function onDelete(){
	 var s = $$('#table input');
	 var trs = $$('#table tr');
	 for(var i=s.length-1; i>=0; i--)
	 {
	  if (s[i].checked)
	   trs[i].remove();
	 }

}
function checkForm(){
	var checked = "";
    $$('input[type="checkbox"][name="itemID"]').select(function(i){return i.checked}).each(function(i)
    {
       //alert(i.value)
       checked = checked + i.value;
	});  
    if(checked=="") {
        alert("请选择一个事务");
        return false;
    }
    return true;
	
} 


function submitForm(method) {
	var ret = true;
	if(method!="add") {
	    ret = checkForm()
	}
	if(ret) {
	    $("method").value=method;
	    $("itemsForm").submit();
	}
}
</SCRIPT>
</head>
<body>
<div id="content"><div id="content_inner">
<center>
<h2>
<c:choose>
<c:when test="${param.itemType==1}">
也许会做的事
</c:when>
<c:when test="${param.itemType==2}">
仅作参考
</c:when>
<c:when test="${param.itemType==3}">
健康清单
</c:when>
<c:when test="${param.itemType==4}">
生日清单
</c:when>
<c:when test="${param.itemType==5}">
维修清单
</c:when>
<c:when test="${param.itemType==6}">
假日清单
</c:when>
<c:when test="${param.itemType==7}">
清洁清单
</c:when>
<c:when test="${param.itemType==8}">
幸福感清单
</c:when>
<c:otherwise>
待处理事务
</c:otherwise>
</c:choose>
</h2>
</center>

<form name="itemsForm" id="itemsForm" method="get" action="item.htm">
<display:table htmlId="itemList" name="itemList" sort="list" 
     class="its" id="item" requestURI="item.htm">
<display:setProperty name="basic.empty.showtable" value="true" />
<display:setProperty name="basic.msg.empty_list_row" value="<tr class='empty'><td colspan='{0}'>没有记录</td></tr>"/>
<display:column title="" sortable="true" headerClass="sortable">
<INPUT TYPE="checkbox" NAME="itemID" ID="itemID" value="${item.itemID}" >
</display:column>
<display:column title="事务" sortable="true" headerClass="sortable">
<a href="item.htm?method=edit&itemID=${item.itemID}&itemType=${param.itemType}">${item.itemName}</a>
</display:column>
<display:column property="description" title="细节" sortable="true" headerClass="sortable"/>
<display:column title="类别" sortable="true" headerClass="sortable">
${categories[item.categoryID].description}
</display:column>
<display:column title="创建时间" sortable="true" headerClass="sortable">
<fmt:formatDate value="${item.createTime}" pattern="MM/dd/yy HH:mm:ss"/>
</display:column>
<display:column title="操作" class="taskOperation">
<a href="item.htm?method=edit&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_edit" title="Edit Task"><span>Edit Item</span></a>
<a href="item.htm?method=delete&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_delete" title="Delete Task"><span>Delete Item</span></a>
</display:column> 
</display:table>
<div id="itemAction">
<input type="hidden" name="method" id="method">
<input type="hidden" name="itemType" id="itemType" value="${param.itemType}">
<INPUT TYPE="checkbox" name="checkAllBox" id="checkAllBox" onclick="checkAll('checkAllBox')">
<input type="button" onclick="submitForm('add')" value="添加事务"/>
<c:if test="${empty param.itemType}">
<input type="button" name="asTask" onclick="submitForm('asTask')" value="作为任务"/>
<input type="button" name="asMemo" onclick="submitForm('asMemo')"  value="作为备忘"/>
<input type="button" name="asRefer" onclick="submitForm('asRefer')"  value="作为参考"/>
</c:if>
</div>
</form>
</div><!-- content_inner -->
</div><!-- content -->
</body>
</html>